<template>
  <div class="viewcontainer" v-if="dataset">
    <hi-toolbar :source="dataset" v-bind="toolbar"></hi-toolbar>
    <el-row>
      <el-col :span="24">
        <h2 class="viewcontainer_title">基本信息</h2>
        <!-- <hr /> -->
      </el-col>
    </el-row>
    <hi-form
      :dataSource="dataset"
      ref="detailLicenseForm"
      :model="dataset.curRecord"
      v-bind="form"
    ></hi-form>
    <el-row>
      <el-col :span="24">
        <h2 class="viewcontainer_title">证照有效期</h2>
        <!-- <hr /> -->
      </el-col>
    </el-row>
    <hi-form
      ref="detailForm"
      :model="dataset.curRecord"
      :dataSource="dataset"
      v-bind="formLicense"
    ></hi-form>
  </div>
</template>

<script>
import { HiForm, DataSetContainer, HiToolbar } from "hi-ui";
import viewBase from "../../base";
import datasetCfg from "./dataset";

export default {
  name: "supplierdetail",
  extends: viewBase,
  components: { HiForm, HiToolbar },

  data() {
    let dataset = null;
    return {
      //数据集配置
      datasetCfg: datasetCfg,

      //数据集
      dataset: dataset,
      toolbar: {
        buttons: [
          {
            kind: "save",
            type: "danger",
            icon: "el-icon-upload",
          },
        ],
      },
      //数据桥梁
      dataBridge: new Map(),
      //编辑数据
      editData: {},
      //许可证表单
      formLicense: {
        columnsTotal: 4,
        colPercents: [1, 2, 1, 2],
        lblWidths: [80, 180, 80, 180],
        items: [
          {
            name: "FBUSINESSLICENSEIMG",
            label: "",
            rowspan: 3,
            element: "hi-upload",
            props: {
              hideUpload: true,

              "with-credentials": true,
              accept: "image/png, image/jpeg",
              limit: 1,
              // "show-file-list":false,
              // disabled:true,
              multiple: true,
              "list-type": "picture-card",
            },
          },

          {
            element: "el-input",
            label: "营业执照号",
            name: "FBUSINESSLICENSEID",
            props: {
              maxlength: 20,
            },
          },
          {
            name: "FDRUGLICENSEIMG",
            label: "",
            rowspan: 3,
            element: "hi-upload",
            props: {
              hideUpload: true,

              "with-credentials": true,
              accept: "image/png, image/jpeg",
              limit: 1,
              // "show-file-list":false,
              // disabled:true,
              multiple: true,
              "list-type": "picture-card",
            },
          },
          {
            element: "el-input",
            label: "药品许可证号",
            name: "FDRUGLICENSEID",

            props: {
              maxlength: 20,
            },
          },

          {
            element: "el-date-picker",
            label: "营业执照有效期",
            name: "FBUSINESSLICENSEDATE",
            props: {
              type: "date",
            },
          },
          {
            element: "el-date-picker",
            label: "药品许可证有效期",
            name: "FDRUGLICENSEDATE",
            props: {
              type: "date",
            },
          },
          {
            element: "el-input",
            label: "营业执照经营范围",
            name: "FBUSINESSLICENSESCOPE",
            rowspan: 1,
            props: {
              maxlength: 200,
              type: "textarea",
              autosize: { minRows: 4, maxRows: 4 },
            },
          },
          {
            element: "el-input",
            label: "药品许可证经营范围",
            name: "FDRUGLICENSESCOPE",
            rowspan: 1,

            props: {
              maxlength: 200,
              type: "textarea",
              autosize: { minRows: 4, maxRows: 4 },
            },
          },

          {
            name: "FGSPLICENSEIMG",
            label: "",
            rowspan: 3,
            element: "hi-upload",
            props: {
              hideUpload: true,

              "with-credentials": true,
              accept: "image/png, image/jpeg",
              limit: 1,
              // "show-file-list":false,
              // disabled:true,
              multiple: true,
              "list-type": "picture-card",
            },
          },
          {
            element: "el-input",
            label: "GMP/GSP许可证号",

            name: "FGSPLICENSEID",

            props: {
              maxlength: 20,
            },
          },
          {
            name: "FMEDICALINSTRUMENTIMG",
            label: "",
            rowspan: 3,
            element: "hi-upload",
            props: {
              hideUpload: true,

              "with-credentials": true,
              accept: "image/png, image/jpeg",
              limit: 1,
              // "show-file-list":false,
              // disabled:true,
              multiple: true,
              "list-type": "picture-card",
            },
          },
          {
            element: "el-input",
            label: "医疗器械许可证号",
            name: "FMEDICALINSTRUMENTID",

            props: {
              maxlength: 20,
            },
          },

          {
            element: "el-date-picker",
            label: "GMP/GSP许可证有效期",
            name: "FGSPLICENSEDATE",

            props: {
              type: "date",
            },
          },
          {
            element: "el-date-picker",
            label: "医疗器械许可证有效期",
            name: "FMEDICALINSTRUMENTDATE",

            props: {
              type: "date",
            },
          },
          {
            element: "el-input",
            label: "GMP/GSP许可证经营范围",
            name: "FGSPLICENSESCOPE",
            rowspan: 1,
            props: {
              maxlength: 200,
              type: "textarea",
              autosize: { minRows: 4, maxRows: 4 },
            },
          },
          {
            element: "el-input",
            label: "医疗器械许可证经营范围",
            name: "FMEDICALINSTRUMENTSCOPE",
            rowspan: 1,
            props: {
              maxlength: 200,
              type: "textarea",
              autosize: { minRows: 4, maxRows: 4 },
            },
          },

          {
            name: "FHEALTHLICENSEIMG",
            label: "",
            rowspan: 3,
            element: "hi-upload",
            props: {
              hideUpload: true,

              "with-credentials": true,
              accept: "image/png, image/jpeg",
              limit: 1,
              // "show-file-list":false,
              // disabled:true,
              multiple: true,
              "list-type": "picture-card",
            },
          },
          {
            element: "el-input",
            label: "卫生许可证号",
            name: "FHEALTHLICENSEID",
            colspan: 1,
            props: {
              maxlength: 20,
            },
          },
          {
            name: "FFOODBUSINESSLICENSEIMG",
            label: "",
            rowspan: 3,
            element: "hi-upload",
            props: {
              hideUpload: true,

              "with-credentials": true,
              accept: "image/png, image/jpeg",
              limit: 1,
              // "show-file-list":false,
              // disabled:true,
              multiple: true,
              "list-type": "picture-card",
            },
          },
          {
            element: "el-input",
            // label: "食品经营许可证号",
            name: "FFOODBUSINESSLICENSEID",
            colspan: 1,
            props: {
              maxlength: 20,
            },
          },
          // { element: "div", colspan: 1 },

          {
            element: "el-date-picker",
            label: "卫生许可证有效期",
            name: "FHEALTHLICENSEDATE",
            colspan: 1,
            props: {
              type: "date",
            },
          },
          {
            element: "el-date-picker",
            label: "食品经营许可证有效期",
            name: "FFOODBUSINESSLICENSEDATE",
            colspan: 1,
            props: {
              type: "date",
            },
          },

          {
            element: "el-input",
            label: "卫生许可证经营范围",
            name: "FHEALTHLICENSESCOPE",
            colspan: 1,
            rowspan: 1,
            props: {
              maxlength: 200,
              type: "textarea",
              autosize: { minRows: 4, maxRows: 4 },
            },
          },
          {
            element: "el-input",
            label: "食品经营许可证经营范围",
            name: "FFOODBUSINESSLICENSESCOPE",
            rowspan: 1,

            props: {
              maxlength: 200,
              type: "textarea",
              autosize: { minRows: 4, maxRows: 4 },
            },
          },
          { element: "div", colspan: 1 },
          {
            element: "el-input",
            label: "组织机构代码号",
            name: "FORGCODE",
            colspan: 1,
            props: {
              maxlength: 20,
            },
          },
          { element: "div", colspan: 1 },
          {
            element: "el-date-picker",
            label: "法人授权有效期",
            name: "FLEGALPERSONAUTHDATE",
            colspan: 1,
            props: {
              type: "date",
            },
          },
          { element: "div", colspan: 1 },
          {
            element: "el-date-picker",
            label: "质量保证有效期",
            name: "FQUALITYASSURANCEDATE",
            colspan: 1,
            props: {
              type: "date",
            },
          },
          { element: "div", colspan: 1 },
          {
            element: "el-date-picker",
            label: "购销合同有效期",
            name: "FPURCHASECONTRACTDATE",
            colspan: 1,
            props: {
              type: "date",
            },
          },
        ],
      },
      //表单配置
      form: {
        columnsTotal: 2,
        items: [
          {
            name: "FDESC",
          },

          {
            name: "FENTERPRISEPERSON",
          },

          {
            name: "FENTERPRISESUPERVISOR",
          },
          {
            name: "FQUALITYSUPERVISOR",
          },

          {
            name: "FCONTACTMAN",
          },
          {
            name: "FCONTACTTEL",
          },

          {
            name: "FFAX",
          },
          {
            name: "FADDRESS",
          },
          {
            name: "FZIPCODE",
          },
          {
            name: "FEMAIL",
          },

          {
            name: "FBUSINESSTYPE",
            element: "hi-select-grid",
            props: {
              selectOption: {
                // remote:true,
                loading: true,
                multiple: false,
                clearable: true,
                filterable: true,
                "allow-create": true,
                "collapse-tags": true,
              },
              lookup: {
                modelFile: "database/base/dataset/BaseEntity.xml",
                param: { FPID: "jylx" },
                tableprops: {
                  // border:true,
                  //stripe:true,
                  "show-header": false,
                  //fit:false,
                  size: "mini",
                  "max-height": 400,
                },
                returnFields: {
                  FBUSINESSTYPE: "FDESC",
                  FBUSINESSTYPEID: "FVALUE",
                },
                columns: [
                  {
                    name: "FDESC",
                    label: "经营类型",
                  },
                ],
              },
            },
          },

          {
            name: "FBUSINESSSCOPE",
            colspan: 2,
            props: {
              type: "textarea",
              autosize: { minRows: 4, maxRows: 4 },
              maxlength: 200,
            },
          },

          {
            name: "FCERTIFICATION",
            element: "hi-select-grid",
            props: {
              selectOption: {
                // remote:true,
                loading: true,
                multiple: false,
                clearable: true,
                filterable: true,
                "allow-create": true,
                "collapse-tags": true,
              },
              lookup: {
                modelFile: "database/base/dataset/BaseEntity.xml",
                param: { FPID: "rzlb" },
                tableprops: {
                  // border:true,
                  //stripe:true,
                  "show-header": false,
                  //fit:false,
                  size: "mini",
                  "max-height": 400,
                },
                returnFields: {
                  FCERTIFICATION: "FDESC",
                  FCERTIFICATIONID: "FVALUE",
                },
                columns: [
                  {
                    name: "FDESC",
                    label: "认证类别",
                  },
                ],
              },
            },
          },

          {
            name: "FCUSTOMERCATEGORY",
            element: "hi-select-grid",
            props: {
              selectOption: {
                // remote:true,
                loading: true,
                multiple: true,
                clearable: true,
                filterable: true,
                "allow-create": true,
                "collapse-tags": true,
              },
              lookup: {
                modelFile: "database/base/dataset/BaseEntity.xml",
                param: { FPID: "gyslx" },
                tableprops: {
                  // border:true,
                  //stripe:true,
                  "show-header": false,
                  //fit:false,
                  size: "mini",
                  "max-height": 400,
                },
                returnFields: {
                  FCUSTOMERCATEGORY: "FDESC",
                  FCUSTOMERCATEGORYID: "FVALUE",
                },
                columns: [
                  {
                    name: "FDESC",
                    label: "供应商类型",
                  },
                ],
              },
            },
          },
          {
            name: "FSALESMAN",
          },
          {
            name: "FSALESMANIDCARD",
          },
          {
            name: "FAREA",
          },
          {
            name: "FBANK",
          },
          {
            name: "FTAXID",
          },
          {
            element: "el-input",
            label: "银行帐户",
            name: "FBANKACCOUNT",
            props: {
              maxlength: 20,
            },
          },
          {
            element: "el-input",
            label: "备注",
            colspan: 2,
            name: "FNOTE",
            props: {
              type: "textarea",
              autosize: { minRows: 4, maxRows: 4 },
              maxlength: 200,
            },
          },
        ],
      },
    };
  },
  model: {
    prop: "value",
    event: "valuechange",
  },
  props: {
    value: {
      type: Object,
    },
  },

  computed: {},
  watch: {},
  methods: {
    test() {
      debugger;
    },
  },
  mounted() {
    this.dataset = this.createDataSet(this.datasetCfg);

    this.dataset.on("aftersave", (res, store) => {
      if (res.status == 200) {
        this.closepage();
      }
    });
    this.dataBridge.set(this.dataset, ["detailForm", "detailLicenseForm"]);
    if (this.$route.query.id) {
      this.dataset.load({
        FID: this.$route.query.id,
      });
    }
  },
};
</script>
<style rel="stylesheet/scss" lang="scss" scope>
.viewcontainer_title {
  font-size: 16px;
  line-height: 46px;
  font-weight: bold;
  padding: 0 20px;
}
</style>

